/*
function menuDropDown(obj_id)
{
	var ul = document.getElementById(obj_id);
	if(ul.style.display=="block")
	{
		ul.style.display="none";
	}else
	{
		ul.style.display="block";
	}
}

function updateContainer(sub_menu)
{
	switch(sub_menu) {
	case 'economy':
		$("#container").load("economy.php");
		break;
	case 'society':
		$("#container").load("society.php");
		break;
	case 'ecology':
		$("#container").load("ecology.php");
		break;
	default:
		return;
	}
	
}*/

/*******************************************利用模版之后js*************************************/
//发展业绩 根据条件过滤记录，由于加入分页功能，该函数不能继续使用
/*function selectFilter()
{
	var obj_area = document.getElementById("select_area");
	var index = obj_area.selectedIndex;
	var area = obj_area.options[index].text;
	
	var obj_time = document.getElementById("select_time");
	var index = obj_time.selectedIndex;
	var time = obj_time.options[index].text;
	
	var obj_indicator = document.getElementById("select_indicator");
	var index = obj_indicator.selectedIndex;
	var indicator = obj_indicator.options[index].text;
	
	var tr = document.getElementById("economy_list").getElementsByTagName("tr");
	var len = tr.length;
	
	for(var i = 1; i < len; i++){            
		var tdnode=tr[i].cells;
		if(tdnode.length==5)
		{
			if((tdnode[0].innerHTML==area || area==obj_area.options[0].text) 
					&& (tdnode[1].innerHTML==time || time==obj_time.options[0].text)
					&& (tdnode[2].innerHTML==indicator || indicator == obj_indicator.options[0].text))
			{
				tr[i].style.display="";
			}else{
				tr[i].style.display="none";
			}
		}
	}
}*/

//ajax 实现保存
var xmlHttp;
function updatePerformanceItem()
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	  alert ("Browser does not support HTTP Request");
	  return;
	} 
	
	var area = document.getElementById("edit_area").value;
	var time = document.getElementById("edit_time").value;
	var indicator = document.getElementById("edit_indicator").value;
	var value = document.getElementById("edit_value").value;
	var id = document.getElementById("edit_id").value;
	//var index = obj_area.selectedIndex;
	//var area = obj_area.options[index].text;
	
	var url="../../web/ajax/saveItem.php";
	url=url+"?id="+id;
	url=url+"&area="+area;
	url=url+"&time="+time;
	url=url+"&indicator="+indicator;
	url=url+"&value="+value;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function newDeletePerformanceItem(id,obj)
{

	obj.parentNode.style.display="none";
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	  alert ("Browser does not support HTTP Request");
	  return;
	}
	var url="../../web/ajax/deleteItem.php";
	url=url+"?id="+id;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		var obj = document.getElementById("edit_tip");
		obj.style.display="block";
	} 
}


function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function deletePerformanceItem()
{
	alert("您确定要删除该项记录吗？");
}

function checkAddItem()
{
	var area = document.getElementById("new_area").value;
	var time = document.getElementById("new_time").value;
	var indicator = document.getElementById("new_time").value;
	var value = document.getElementById("new_value").value;
	
	
	if(area==""){ alert("区域不能为空"); return false;}
	if(time=="") { alert("时间不能为空"); return false;}
	if(indicator=="") { alert("指标不能为空"); return false;}
	if(value==""){ alert("指标值不能为空"); return false;}
	return true;
}
/******************************************************************************************/
function updateMemberItem()
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	  alert ("Browser does not support HTTP Request");
	  return;
	} 
	
	var id = document.getElementById("edit_id").value;
	var name = document.getElementById("edit_name").value;
	var profession = document.getElementById("edit_profession").value;
	var department = document.getElementById("edit_department").value;
	var tel = document.getElementById("edit_tel").value;
	var tax = document.getElementById("edit_tax").value;
	var email = document.getElementById("edit_email").value;
	//alert("," + id +"," + name + "," + profession +"," + department +"," + tel +"," + tax + "," + email );
	var url="../../web/ajax/saveItemMember.php";
	url=url+"?id="+id;
	url=url+"&name="+name;
	url=url+"&profession="+profession;
	url=url+"&department="+department;
	url=url+"&tel="+tel;
	url=url+"&tax="+tax;
	url=url+"&email="+email;
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function updateEconomicItem()
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	  alert ("Browser does not support HTTP Request");
	  return;
	} 
	
	var id = document.getElementById("edit_id").value;
	var name = document.getElementById("edit_name").value;
	var year = document.getElementById("edit_year").value;
	var month = document.getElementById("edit_month").value;
	var value = document.getElementById("edit_value").value;
	var unit = document.getElementById("edit_unit").value;
	
	var url="../../web/ajax/saveItemEconomic.php";
	url=url+"?id="+id;
	url=url+"&name="+name;
	url=url+"&year="+year;
	url=url+"&month="+month;
	url=url+"&value="+value;
	url=url+"&unit="+unit;
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

/************************************* 分页 ******************************************/
/* 经济子系统分页 */
function pageLink(pageNo)
{
	//location.href='../../index.php?PerformanceController/showEconomyList/'+ pageNo;
	input = document.getElementById('pageNo');
	input.value = pageNo;
	document.getElementById('filter').submit();
}
/************************************* 分页结束 ******************************************/



